package lab02.test17;

import java.util.Scanner;

public class Test17 {
    public static void main(String[] args) {
        //创建数组的大小
        int []numberArr = new int[10];

        //录入十个数据
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入十个数字：");
        for (int i = 0;i < 10;i ++){
            numberArr[i] = sc.nextInt();
        }

        //初始化最大，最小，位置的数据
        int max = numberArr[0];
        int min = numberArr[0];
        int loca1 = 0;
        int loca2 = 0;

        //比较元素的大小获取最大和最小的值
        for (int i = 0;i <numberArr.length;i++){
            if(numberArr[i] > max){
                max = numberArr[i];
                loca1 = i;
            }else if (numberArr[i] < min){
                min = numberArr[i];
                loca2 = i;
            }
        }

        System.out.println("最大值为："+max);
        System.out.println("最小值："+min);
        System.out.println("最大值所处的位置为："+loca1);
        System.out.println("最小值所处的位置为："+loca2);

    }
}
